var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
require('dotenv').config();
const cors = require('cors')


var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

// 后台路由文件
const adminAuthRouter = require('./routes/admin/auth');

var app = express();
// CORS 跨域配置
app.use(cors());

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

// 后台路由配置
app.use('/admin/auth', adminAuthRouter);

app.use('/', indexRouter);
app.use('/users', usersRouter);

module.exports = app;
// sequelize model:generate --name User --attributes username:string,password:string,email:string,phone:string,role:string